/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.asseco.mio.codex.controllers;

import com.asseco.mio.BasicInfo;
import com.asseco.mio.UserInstitution;
import com.asseco.mio.WorkPosition;
import com.asseco.mio.codex.FirstLoginModel;
import com.asseco.mio.core.webapp.controller.BaseFormController;
import com.asseco.mio.search.UserSearch;
import com.asseco.persistence.service.HibernateUtil;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.appfuse.model.Role;
import org.appfuse.model.User;
import org.appfuse.service.GenericManager;
import org.appfuse.service.UserManager;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author gjoko.mitrovski
 */
@Controller
@RequestMapping("/firstlogintest*")
public class FirstLoginTest {

    private UserManager userManager = null;
    private Locale locale;

    @Autowired
    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }
    private GenericManager<FirstLoginModel, String> firstLoginManager;

    @Autowired
    public void setFirstLoginManager(@Qualifier("firstLoginManager") GenericManager<FirstLoginModel, String> firstLoginManager) {
        this.firstLoginManager = firstLoginManager;
    }

    @ModelAttribute
    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
    protected ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
         
        //TODO
        // da se dodade kod za proverka na admin
       FirstLoginCheck x = new FirstLoginCheck();
       if (x.isFirstLogin(request.getRemoteUser())) {

            return new ModelAndView("resetpassword").addObject("user", new User());
        }
       return new ModelAndView("mainMenu");
    }

   
}
